/** CODE EVAL:Easy [Calculate Distance]
 *	Given two coordinates calculate the distance between them
 *
 *	Distance Formula:
 *		d = sqrt( (x2-x1)^2 + (y2-y1)^2 )
 *
 *	Solution by Michael Pio Arroyo
 */

#include <iostream>
#include <fstream>
#include <string>
#include <math.h>
#include <stdlib.h>

struct Point {
	int x, y;
};

void GetPoints(std::string a_line, Point& a_pointA, Point& a_pointB);
void DoMath(Point a_pointA, Point a_pointB);

int main(int argc, char** argv) {
	std::ifstream file;
	std::string line;
	Point A, B;
	file.open(argv[1]);

	while(getline(file, line)) {
		GetPoints(line, A, B);
		DoMath(A, B);
	}

	file.close();
	return 0;
}

/** 
 *	Get int values for each point
 *	@param a_line...string containing coordinates
 *	@param &a_pointA...first coordinate
 *	@param &a_pointB...second coordinate
 */
void GetPoints(std::string a_line, Point& a_pointA, Point& a_pointB) {
	size_t len = a_line.length();
	std::string t;
	std::string::iterator it = a_line.begin();
	// get point A.x
	while(*it != ',') {
		if(*it != '(')
			t.push_back(*it);
		++it;
	}
	a_pointA.x = atoi(t.c_str());	// convert to int
	t.clear();	// clear for next number
	++it;	// skip ','
	// get point A.y
	while(*it != ')') {
		if(*it != ' ')
			t.push_back(*it);
		++it;
	}
	a_pointA.y = atoi(t.c_str());
	t.clear();
	++it;
	// get point B.x
	while(*it != ',') {
		if(*it != ' ' && *it != '(')
			t.push_back(*it);
		++it;
	}
	a_pointB.x = atoi(t.c_str());
	t.clear();
	++it;
	// get point B.y
	while(*it != ')') {
		if(*it != ' ')
			t.push_back(*it);
		++it;
	}
	a_pointB.y = atoi(t.c_str());
	t.clear();
	++it;
}

/**
 *	Calculate distance between both points & display
 *	@param a_pointA...first coordinate
 *	@param a_pointB...second coordinate
 */
void DoMath(Point a_pointA, Point a_pointB) {
/**
 *	Distance Formula:
 *		d = sqrt( (x2-x1)^2 + (y2-y1)^2 )
 */
	int d = sqrt(((a_pointB.x-a_pointA.x)*(a_pointB.x-a_pointA.x)) + ((a_pointB.y-a_pointA.y)*(a_pointB.y-a_pointA.y)));
	std::cout << d << '\n';
}